package com.example.springboottools.utils;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class FileUtils {

    public static void main(String[] args) {

        // P00  P00
        File file = new File("D:\\staples\\日常记录\\工作记录\\2024\\04\\15\\文件\\20240412_HTML202404121712902380542\\详图\\");
        File[] files = file.listFiles();
        System.out.println("================================================================================");
        for (File f : files) {
            System.out.println(f.getName());
        }
        System.out.println("================================================================================");
    }


    public static String readBufReadFile(String filePath) {
        StringBuffer sb = new StringBuffer();
        try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
            String line;
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
    public static String readScannerReadFile(String filePath) {
        StringBuffer sb = new StringBuffer();
        try (Scanner scanner = new Scanner(new File(filePath))) {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                sb.append(line);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
}
